package com.kly.ai.rags;

import com.alibaba.cloud.ai.dashscope.api.DashScopeApi;
import com.alibaba.cloud.ai.dashscope.rag.DashScopeDocumentRetriever;
import com.alibaba.cloud.ai.dashscope.rag.DashScopeDocumentRetrieverOptions;
import org.springframework.ai.chat.client.advisor.RetrievalAugmentationAdvisor;
import org.springframework.ai.chat.client.advisor.api.Advisor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author admin
 * @date 2025/5/29
 */
@Component
public class LoadDocumentCloud {

    @Value("${spring.ai.dashscope.api-key}")
    private String apiKey;

    /**
     * 加载恋爱知识advisor
     *
     * @return
     */
    @Bean
    public Advisor loadLoveDocumentsAdvisor() {
        DashScopeApi dashScopeApi = new DashScopeApi(apiKey);
        DashScopeDocumentRetriever documentRetriever = new DashScopeDocumentRetriever(
                dashScopeApi,
                DashScopeDocumentRetrieverOptions
                        .builder()
                        .withIndexName("恋爱助手")
                        .build()
        );


        return RetrievalAugmentationAdvisor.builder()
                .documentRetriever(documentRetriever)
                .build();
    }

    // /**
    //  * 加载心理咨询advisor
    //  */
    // @Bean
    // public Advisor loadPsychicDocumentsAdvisor() {
    //     DashScopeApi dashScopeApi = new DashScopeApi(apiKey);
    //     DashScopeDocumentRetriever documentRetriever = new DashScopeDocumentRetriever(
    //             dashScopeApi,
    //             DashScopeDocumentRetrieverOptions.builder()
    //                     .withIndexName("psychologist")
    //                     .build()
    //     );
    //
    //     return RetrievalAugmentationAdvisor.builder()
    //             .documentRetriever(documentRetriever)
    //             .build();
    // }

}
